ini_open


描述

这将打开一个用于读取和 / 或写入的 ini_file。如果你正在检查的位置不存在 ini_file,GameMaker Studio 2可能会创建一个,但前提是你向其写入数据。If you have only read information from the ini file, then the default values for the read function will be returned, but the ini file will not actually be created.

Please note that you can only have one ini file open at any one time and remember to use ini_close once you're finished reading/writing from the .ini file as the information is not actually stored to disk until then (it is also stored in memory until the file is closed).

警告! 由于 GameMaker Studio 2 被沙箱化,这些函数可能无法正常工作!有关详细信息,请参阅 文件系统限制 部分。


语法:

ini_open(name);


参数 描述
name ini 文件的文件名


返回:

N/A(无返回值)


例如:

ini_open("Settings/savedata.ini");
score = ini_read_real("save1", "score", 0);
ini_close();

这将打开 'savedata.ini' 并读取 “save1” 节中的 “score” 键代表的分数值,然后再次关闭 .ini。如果 “save1” 节 “score” 键没有值,或者没有 “savedata.ini” 文件,则得分将设置为 0(默认值)。Note that the ini file has been placed in the subdirectory "Settings", which is the folder that holds the INI file in the resource tree included files.